/*
 * @lc app=leetcode.cn id=11 lang=javascript
 *
 * [11] 盛最多水的容器
 */

// @lc code=start
/**
 * @param {number[]} height
 * @return {number}
 */
var maxArea = function(height) {
  let result = 0
  let l = 0
  let r = height.length - 1
  while (l < r) {
    const temp = (r- l) * Math.min(height[l], height[r])
    result = Math.max(temp, result)
    if (height[l] <= height[r]) {
      l++
    } else {
      r--
    }
  }
  return result
};
// @lc code=end

